Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait to load PgSearch::Document until after ActiveRecord has loaded #322

Merged
merged 1 commit into from
Dec 21, 2016

Conversation

lleger
Copy link
Contributor

@lleger lleger commented Aug 23, 2016

Loading the PgSearch::Document model without waiting for ActiveRecord to
load can cause problems because it causes ActiveRecord to pull
configuration into ActiveRecord::Base before the initializers get
loaded. This means ActiveRecord::Base could accidentally have inaccurate
configuration.

The fix for this is to wait until ActiveRecord has fully loaded before
requiring the model.

ref: rails/rails#23589

Loading the PgSearch::Document model without waiting for ActiveRecord to
load can cause problems because it causes ActiveRecord to pull
configuration into ActiveRecord::Base before the initializers get
loaded. This means ActiveRecord::Base could accidentally have inaccurate
configuration.

The fix for this is to wait until ActiveRecord has fully loaded before
requiring the model.

ref: rails/rails#23589
@lleger
Copy link
Contributor Author

lleger commented Aug 23, 2016

I ran into this issue today. After including the pg_search gem, my specs began to fail. AR changed a config in Rails 5 to add a validation to all belongs_to by default, but that flag is turned on in an initializer. Requiring the PgSearch::Document model before ActiveRecord loaded meant that this config was set to nil, which isn't the right behavior, and caused my specs to fail.

This has happened in a number of gems after the Rails 5 release. Some more reference:

@jkhas8
Copy link

jkhas8 commented Aug 25, 2016

👍 I have the same problem

@nertzy nertzy merged commit d4af95c into Casecommons:master Dec 21, 2016
@lleger
Copy link
Contributor Author

lleger commented Jan 9, 2017

Thanks for merging this @nertzy! Any chance we can get a new release soon so we can switch from our branched version?

@lleger
Copy link
Contributor Author

lleger commented Mar 6, 2017

@nertzy Any plans to release a new version with this and the latest changes from master? Would like to get the official release back into production.

@nertzy
Copy link
Collaborator

nertzy commented Oct 2, 2017

This fix is in v2.1.0 and later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants